package cn.iocoder.yudao.module.api.pay.bill.enums;

import cn.iocoder.yudao.framework.business.basic.enums.EnumCodable;
import com.baomidou.mybatisplus.annotation.EnumValue;
import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.Objects;
import java.util.stream.Stream;

/**
 * 账单资产种类枚举
 */
@Getter
@AllArgsConstructor
public enum BillCategoryEnum implements EnumCodable {

    UNKNOWN("undefined", "未知"),
    MONEY("money", "零钱"),
    RED_PACKET("red_packet", "红包"),
    COMMISSION("commission", "佣金"),
    BONUS("bonus", "分红"),
    INTEREST("interest", "消费金"),
    FEE("fee", "手续费"),
    CRYPTOCURRENCY_ORIGIN("cryptocurrency_origin", "联盟豆"),
    CRYPTOCURRENCY_INCREMENT("cryptocurrency_increment", "收益豆"),
    ;

    @EnumValue
    private final String code;
    private final String name;

    public static BillCategoryEnum codeOf(String code) {
        return Stream.of(values())
                .filter(p -> Objects.equals(p.code, code))
                .findAny()
                .orElse(UNKNOWN);
    }

}
